<template>
	<view class="feedBack">
		<view class="content">
			请把您所需反映的问题录入下面文本框, 我们将24小时内与您联系!
		</view>
		<textarea placeholder="请输入内容" v-model="value" />
		<button @click="confirm" :disabled="status ? true : false">确认提交</button>
	</view>
</template>

<script>
	import { post } from "../../api/index.js"
	import paths from "../../config/path.js"
	export default {
		data() {
			return {
				value: "",
				status: false
			}
		},
		methods: {
			confirm() {
				// 表情正则判断
				let reg = /([^\u0020-\u007E\u00A0-\u00BE\u2E80-\uA4CF\uF900-\uFAFF\uFE30-\uFE4F\uFF00-\uFFEF\u0080-\u009F\u2000-\u201f\u2026\u2022\u20ac\r\n])|(\s)/g
				let url = paths.feedBack
				let userId = uni.getStorageSync("userInfo")
				if(this.value == "") {
					uni.showToast({
						title: "请输入内容!",
						icon: "none"
					});
				} else if(reg.test(this.value)) {
					uni.showToast({
						title: '不支持此类型内容',
						icon: 'none'
					})
				} else {
					this.status = true
					post(url, {
						userid_locked: userId.userid_locked,
						feedback: this.value
					}).then(res => {
						// console.log(res)
						uni.showLoading({
							title: "提交中...",
							success: function(){
								if(res.data.code == "2") {
									setTimeout(() => {
										uni.showToast({
											title: "提交成功",
											success: function(){
												uni.navigateBack({
													delta: 1
												})
											}
										})
									},1000)
								}
							}
						})
					})
				}
			}
		}
	}
</script>

<style scoped>
	.feedBack {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 20rpx;
	}
	
	.content {
		padding-bottom: 20rpx;
		letter-spacing: 1px;
		font-weight: bold;
		line-height: 50rpx;
	}
	
	textarea {
		width: 100%;
		height: 600rpx;
		border: 1px solid #EAEAEA;
		margin: 20rpx 0 150rpx 0;
	}
	
	button {
		background-color: #0DA297;
		color: #FFFFFF;
		letter-spacing: 1px;
		border-radius: 999px;
		width: 80%
	}
	button:active {
		background-color: #cfcfcf;
	}
</style>
